class Solution:
    """
    @param num: a string
    @return: true if a number is strobogrammatic or false
    """
    def isStrobogrammatic(self, num):
        num_map = {'0': '0', '1': '1', '6': '9', '8': '8', '9': '6'}
        i = 0
        j = len(num) - 1
        while i <= j:
            if not num[i] in num_map or num_map[num[i]] != num[j]:
                return False  
            i+=1 
            j-=1
        return True